package com.my.style.ui.fragment;


import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.my.style.adapter.DesignAdapter;
import com.my.style.basemodul.R;
import com.my.style.other.RotateDownPageTransformer;
import com.my.style.ui.activity.DesignActivity;
import com.sv.jm.baselibrary.base.BaseFragment;
import com.sv.jm.baselibrary.event.EventAction;

/**
 * A simple {@link Fragment} subclass.
 */
public class DesignFragment extends BaseFragment {
    ViewPager mViewPager;
    DesignAdapter adapter;
    Button btnDesign;
    @Override
    public int getFragmentLayout() {
        return R.layout.fragment_my;
    }

    @Override
    public void OnCoustomLayoutCreated(View v) {
        mViewPager = findView(v, R.id.id_viewpager);
        btnDesign = findView(v, R.id.btnDesign);
        //设置Page间间距
        mViewPager.setPageMargin(20);
        //设置缓存的页面数量
        mViewPager.setOffscreenPageLimit(3);

        adapter = new DesignAdapter(getContext());
        mViewPager.setPageMargin(40);
        mViewPager.setOffscreenPageLimit(3);
        mViewPager.setPageTransformer(false,new RotateDownPageTransformer());
        mViewPager.setAdapter(adapter);

    }

    @Override
    public void setListeners() {
        btnDesign.setOnClickListener(this);
    }

    @Override
    public void setDatas() {
       String[] images = {
               "http://s1.dwstatic.com/group1/M00/A3/9F/a39f7b05f4e1c492af722d0c6346ff208149.jpg"
               ,"http://s1.dwstatic.com/group1/M00/50/E3/50e3a97fcd1fcd3ae4f2224a98b7b2929957.jpg"
               ,"http://s1.dwstatic.com/group1/M00/5F/B8/5fb856b2f1147721ec4659a96f4142121296.jpg"
               ,"http://s1.dwstatic.com/group1/M00/C8/A7/c8a7294e0de19efc2b84cf0e1f8b01145832.jpg"
               ,"http://s1.dwstatic.com/group1/M00/2B/8F/2b8f85eb990000db80fdea37624e19778016.jpg"
               ,"http://s1.dwstatic.com/group1/M00/A2/41/a241671d62d281b65fdc0234425885b59268.jpg"
               ,"http://s1.dwstatic.com/group1/M00/8F/D2/8fd2118e6b1923b8e7b5c89288c7340c9192.jpg"};
        adapter.setDatas(images);
    }

    @Override
    public void otherClick(View v) {
        if (v==btnDesign){
            startActivity(new Intent(getContext(), DesignActivity.class));
        }
    }

    @Override
    protected void onRefreshData() {

    }

    @Override
    public void onOtherActionReceiver(EventAction eventAction) {

    }
}
